package com.mingtu.dzpatrol.view;

import android.app.Activity;
import android.content.Context;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.FrameLayout;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import com.mingtu.dzpatrol.R;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
import butterknife.Unbinder;

/**
 * @ClassName :
 * @Author : wkk
 * @Date : 2023-10-10 15:19:40
 * @Email : 1281573890@qq.com
 * @Eescription :
 */
public class FilterSureView extends FrameLayout {
    @BindView(R.id.tv_reset)
    TextView tvReset;
    @BindView(R.id.tv_sure)
    TextView tvSure;
    private View view;
    private Unbinder unbinder;
    private Activity activity;
    private OnClickListener onClickListener = null;

    public FilterSureView(@NonNull Context context) {
        this(context, (AttributeSet) null, 0);
    }

    public FilterSureView(@NonNull Context context, @Nullable AttributeSet attrs) {
        this(context, attrs, 0);
    }

    public FilterSureView(@NonNull Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
        view = LayoutInflater.from(context).inflate(R.layout.layout_filter_sure_view, this, true);
        this.activity = (Activity) context;
        unbinder = ButterKnife.bind(this, view);
    }

    @Override
    protected void onAttachedToWindow() {
        super.onAttachedToWindow();
    }

    @Override
    protected void onDetachedFromWindow() {
        super.onDetachedFromWindow();
        unbinder.unbind();
    }

    @OnClick({R.id.tv_reset, R.id.tv_sure})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.tv_reset:
                if (onClickListener != null)
                    onClickListener.onClickReset();
                break;
            case R.id.tv_sure:
                if (onClickListener != null)
                    onClickListener.onClickSure();
                break;
        }
    }

    public void setOnClickListener(OnClickListener onClickListener) {
        this.onClickListener = onClickListener;
    }

    public static interface OnClickListener {

        void onClickReset();

        void onClickSure();
    }
}
